<?php
/* *****************************************************************
 * Procedure: Backend execution via Ajax
 * Author:Cavin @ 23 Aug ,2011
 */
include "../space/pageentry.php";

$db = phpclone($dbObj);
if($aususrtype == '0')
{

}
elseif($aususrtype == '1' || $aususrtype == '2')
{
	if($_GET['tagtype'] == 'replies')
	{
		$sql = "SELECT * FROM `cs_msg_box` WHERE `mid` = '".$_GET['id']."'";
		$result = $db -> getOneQuery($sql);
		if($result)
		{
			if($result['flag'] == '0')
			{
				/*This is new msg*/
				$tempArr = array('flag'=>'1');
				$db -> executeUpdate($tempArr, 'cs_msg_box');
			}
			/*
			 * the return format: sender | content | time
			 */
			$returnMsg = getUsrNickName($result['sender_id']).'##'.$result['content'].'##'.$result['date_time'];
			echo $returnMsg;
		}
		else
		{
			echo 'failed';
		}
	}
	if ($_GET['tagtype'] == 'essay')
	{
		$sql = "SELECT `blog_title`,`blog_content` FROM `". $tableBlogArr[$aususrtype] ."` WHERE `bid` ='".$_GET['id']."'";
		$rs = $db -> getOneQuery($sql);
		if($rs)
		{
			$returnMsg = $id.'|'.$rs['blog_content'].'|'.$rs['blog_title'];
			echo $returnMsg;
		}
		else
		{
			echo 'failed';
		}
	}
	if($_GET['tagtype'] == 'profile')
	{
		$sql = "SELECT `Sort_Name`,`Sort_ID` FROM `cs_sort` WHERE `bMain` = '0' AND `Sort_ID` LIKE '".$_POST['pid']."%' ORDER BY `ID` ASC";
		$rs = $db -> executeQuery($sql);
		if ($rs)
		{
			$body = '';
			foreach ($rs as $val)
			{
				$body .= $val['Sort_ID'].'-'.$val['Sort_Name'].'|';
			}
			echo $body;
		}
		else
		{
			echo 'failed';
		}
	}
}
else
{
	echo 'no';
}